//导入request.js 请求工具
import request from '@/utils/request.js'
//注册
export const userRegisterService = (registerData) => {
    //借助URLSearchParams对象将请求参数对象序列化
    const params = new URLSearchParams()
    for (let key in registerData) {
        //赋值
        params.append(key, registerData[key])
    }
    //返回数据
   return request.post('/user/register', params)

}
//登录
export const userLoginService = (loginData) => {
    //借助URLSearchParams对象将请求参数对象序列化
    const params = new URLSearchParams()
    for (let key in loginData) {
        //赋值
        params.append(key, loginData[key])
    }
    //返回数据
   return request.post('/user/login', params)

}
//获取用户详情信息
export const userInfoService = () => {
    return request.get('/user/userInfo')
}

//修改个人信息
export const userInfoUpdateService = (userInfo)=>{
    return request.put('/user/update',userInfo)
}
//修改头像
export const userAvatarUpdateService=(avatarUrl)=>{
    let params = new URLSearchParams();
    params.append('avatarUrl',avatarUrl)
    return request.patch('/user/updateAvatar',params)


    
}